#ifndef SNIFFER_H
#define SNIFFER_H

#include "pcap.h"
#include <Winsock2.h>
#include <tchar.h>
#include <QDebug>
#include <QList>
#include <QTableWidget>
#include "frame.h"

class Sniffer
{
public:
    static const QStringList fileSuffix;
    Sniffer();
    ~Sniffer();
    //获取系统中的网卡设备
    QList<QString> getAdapters();
    //从文件中读取之前捕获的数据
    void readDump(QString fileName, QTableWidget * table, QStringList filters);
    //启动嗅探器 数据将保存到文件
    static void beginSniff(pcap_if_t *alldevs, int inum);
    static void stopSniff(){doing = false;}
    static void processTCPInfo(QString & info, const tcp_header* header);
    static QString processData(QByteArray & data);


    static bool doing;
    pcap_if_t *alldevs;
private:
    void doRead(struct pcap_pkthdr *header,const u_char *pkt_data,
                int len_ether, QTableWidget * table,
                QStringList filters);
};

#endif // SNIFFER_H
